home *** CD-ROM | disk | FTP | other *** search
/ Practical Internet 2002 February / Practical Internet February 2002.iso / pc / Software / Browsing / httrack-3.09e2.exe / {app} / src / htshash.h < prev    next >
Encoding:
C/C++ Source or Header  |  2001-11-07  |  3.5 KB  |  97 lines

  1. /* ------------------------------------------------------------ */
  2. /*
  3. HTTrack Website Copier, Offline Browser for Windows and Unix
  4. Copyright (C) Xavier Roche and other contributors
  5.  
  6. This program is free software; you can redistribute it and/or
  7. modify it under the terms of the GNU General Public License
  8. as published by the Free Software Foundation; either version 2
  9. of the License, or any later version.
  10.  
  11. This program is distributed in the hope that it will be useful,
  12. but WITHOUT ANY WARRANTY; without even the implied warranty of
  13. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  14. GNU General Public License for more details.
  15.  
  16. You should have received a copy of the GNU General Public License
  17. along with this program; if not, write to the Free Software
  18. Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
  19.  
  20.  
  21. Important notes:
  22.  
  23. - We hereby ask people using this source NOT to use it in purpose of grabbing
  24. emails addresses, or collecting any other private information on persons.
  25. This would disgrace our work, and spoil the many hours we spent on it.
  26.  
  27.  
  28. Please visit our Website: http://www.httrack.com
  29. */
  30.  
  31.  
  32. /* ------------------------------------------------------------ */
  33. /* File: httrack.c subroutines:                                 */
  34. /*       hash table system (fast index)                         */
  35. /* Author: Xavier Roche                                         */
  36. /* ------------------------------------------------------------ */
  37.  
  38.  
  39.  
  40. #ifndef HTSHASH_DEFH
  41. #define HTSHASH_DEFH 
  42.  
  43. #include "htscore.h"
  44.  
  45. // tables de hashage
  46. int hash_read(hash_struct* hash,char* nom1,char* nom2,int type);
  47. void hash_write(hash_struct* hash,int lpos);
  48. int* hash_calc_chaine(hash_struct* hash,int type,int pos);
  49. unsigned long int hash_cle(char* nom1,char* nom2);
  50.  
  51.  
  52.  
  53.  
  54. // inthash -- simple hash table, using a key (char[]) and a value (ulong int)
  55.  
  56. // simple hash table for other routines
  57. typedef struct inthash_chain {
  58.   char* name;                    /* key (name) */
  59.   unsigned long int value;       /* value */
  60.   struct inthash_chain* next;    /* next element */
  61. } inthash_chain;
  62.  
  63. // structure behind inthash
  64. typedef struct {
  65.   inthash_chain** hash;
  66.   int hash_size;
  67.   int flag_valueismalloc;
  68. } struct_inthash;
  69.  
  70. // main inthash type
  71. typedef struct_inthash* inthash;
  72.  
  73. // subfunctions
  74. unsigned long int inthash_key(char* value);
  75. void inthash_init(inthash hashtable);
  76. void inthash_delchain(inthash_chain* hash,int free_int);
  77.  
  78. // main functions:
  79.  
  80.  
  81. /* Hash functions: */
  82. inthash inthash_new(int size);                                       /* Create a new hash table */
  83. int     inthash_created(inthash hashtable);                          /* Test if the hash table was successfully created */
  84. void    inthash_delete(inthash* hashtable);                          /* Delete an hash table */
  85. void    inthash_value_is_malloc(inthash hashtable,int flag);         /* Is the 'value' member a malloc() block? */
  86. /* */
  87. int     inthash_read(inthash hashtable,char* name,long int* value);  /* Read entry from the hash table */
  88. /* */
  89. void    inthash_add(inthash hashtable,char* name,long int value);    /* Add entry in the hash table */
  90. void*   inthash_addblk(inthash hashtable,char* name,int blksize);    /* Add entry in the hash table and set value to a new memory block */
  91. int     inthash_write(inthash hashtable,char* name,long int value);  /* Overwrite/add entry in the hash table */
  92. int     inthash_inc(inthash hashtable,char* name);                   /* Increment entry in the hash table */
  93. /* End of hash functions: */
  94.  
  95.  
  96. #endif
  97.